<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>learning3</title>
</head>
<body>
    <img src="green.jpg" alt="hello" title="world" id="B-picture" onload="getWidthHeight()" />
    <a href="javascript:;" style="display: none" id="B-six" onclick="ycAlla()" onmouseover="changeColor()" onmouseout="backColor()">six gad</a>
    <a href="javascript:;" id="B-haizi" onmouseover="changeBjColor()">yanghaifeng</a>
    <input id="B-inpt" type="text" onblur="yzEmall()" onfocus="yzText()"/>
    <span id="B-erro"></span>

<script type="text/javascript">
    function yzEmall(){
        var inpt = document.getElementById("B-inpt");
        var erro = document.getElementById("B-erro");
        console.log(inpt.value);
        var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
        if (inpt.value == "" ){
         erro.innerText = "oops!!";
        }

        if (!reg.test(inpt.value)) {
            erro.innerText = "no emaill";
        }
    }

    var inpt = document.getElementById("B-inpt");
    inpt.onfocus = function () {
        var erro = document.getElementById("B-erro");
        erro.innerText = "";
    }


    console.log(haizi);
    var haizi = document.getElementById("B-haizi");
    console.log(haizi);
    haizi.onclick = function () {
        //location.href = "http://www.baidu.com";
        var ycSix = document.getElementById("B-six");
        console.log(ycSix);
        ycSix.style.display  = "inline";
    };

    haizi.onmouseover = function () {
        haizi.style.background = "red";
    };

    var allA = document.getElementsByTagName("a");
    function ycAlla() {
        for(var i=0;
            i<allA.length;
            i++){
            console.log(i);
            //allA[i].style.display = "none";
            allA[i].style.color = "red";
        }
    }

    function changeColor() {
        for(var i=0; i<allA.length;i++){
            allA[i].style.color = "yellow";
        }
    }

    function backColor() {
        for(var i=0; i<allA.length;i++){
            allA[i].style.color = "green";
        }

    }

    function jumpBaidu(url,time) {
       // var six = document.getElementById("B-six");
        //six.href = "http://www.2345.com";
        //javascript:; 禁用标签链接
    }

    function eat(tool) {
        console.log("一个人用："+tool+" 去吃饭!");
        if (tool == "kuaizi") {
            console.log("hahahah");
        }
        if (tool == "kuaizi")
            return "吃饱了";
        else
            return "没有吃饱";
    }

    var kEated = eat("kuaizi");
    var sEated = eat("shaozi");
    console.log(eat("yhf"));
console.log(kEated, sEated);

    console.log(x);
    var x=10;

    console.log(add(2,5));
    console.log(add(4,20));
    console.log(add(4,30));
    
    var jianfa = function (a,b) {
        return a-b;
    }


    var picture = document.getElementById("B-picture");
    var altText = picture.alt;
    var titleText = picture.title;
    console.log(altText);
    console.log(titleText);

    //picture.height = "150";
    //picture.width = "100";



    function add(x,y){
        return x+y;
    }
    //picture.onload
    function getWidthHeight () {
        var picture = document.getElementById("B-picture");
        var bigPicture = picture.height/picture.width;
        picture.width = "20";
        picture.height = bigPicture * picture.width;
        console.log(picture.height+"sssssssssss");
        console.log(bigPicture+" Ddddddd");
        console.log("onload::::");
        console.log(picture.height);
        console.log(picture.width);
        console.log(picture.style.height);
        console.log(picture.style.width);
    }




    console.log("not onload::::");
    console.log(picture.height);
    console.log(picture.width);
    console.log(picture.style.height);
    console.log(picture.style.width);

</script>



</body>
</html>